CORS stands for Cross Origin Resource Sharing.
CORS is when Java Script tries to access resource from another Origin/Application.
And not from Origin/Application which served the HTML Page with that Java Script.
Origin/Application includes combination of Protocol, Domain and Port
● so if HTML containing Java Script was served from http://localhost:8080/Hello.html
● and Java Script from that Page tries to access image at http://localhost:8085/SomeImage.png
● then these two URLs represent different Origins/Applications (because they listen at different Ports 8080 vs 8085)
Java Script runs inside Browsers which by default disables CORS.
So if your Spring Boot Application returns HTML Page that contains Java Script that needs to access resource from
another Origin/Application then you need to enable CORS on destination Application (one that contains that resource).
This means that in order to demonstrate CORS we need to create two Spring Boot Applications
● Source Application will run on Port 8080 and it will contain HTML with Java Script calling Destination Application
● Destination Application will run on Port 8085 and here we need to enable CORS
CORS Schema